;Renders box, text when applicable
;TSC format: <NAM<name>$
;Auto-corrects for facepic or not

;Lenght of 1 character = 6 pixels
;2px on left 2px on right for spacing

;Feel free to edit anything in the define section to tweak appearance.


offset 48ba4d


#define
ShowBox=[4BEF00]
NumChar=[4BEF04]
StringLoc=4BEF10

NumLocal=[ebp-14]
StrLocal=[ebp-18]
Counter=[ebp-1C]
CharBuf=[ebp-20]
AddForFace=[ebp-24]

CharWidth=6
BoxLeft=55
BoxUp=173
FaceDist=50

TextLeft=58
TextUp=172
#enddefine

data 0F BE 0D DD 5A 4A 00 83 E1 01
jnz :CanRender
retn
:CanRender
mov eax, showbox
test eax, eax
jnz :DoRender
retn

:DoRender
push ebp
mov ebp, esp
sub esp, 24
mov eax, faceID
test eax, eax
jz :NoFace
mov eax, decimal facedist
:NoFace
mov AddForFace, eax
mov ecx, numchar
mov numlocal, ecx
mov strlocal, stringloc
imul ecx, ecx, CharWidth
add ecx, 2
xor eax, eax
mov al, decimal 80
mov [ebp-10], eax
mov edx, eax
add edx, ecx
add eax, decimal 40
mov [ebp-0C], eax
mov [ebp-8], edx
add eax, 8
mov [ebp-4], eax
push 1A
lea eax, [ebp-10]
push eax
push decimal BOxUp
mov eax, decimal boxleft
add eax, addforface
push eax
push 48F91C
call renderGraphics
add esp, 14
mov eax, decimal 205
mov edx, decimal 120
mov [ebp-10], eax
mov [ebp-C], edx
add eax, 3
mov [ebp-8], eax
add edx, 8
mov [ebp-4], edx
push 1A
lea eax, [ebp-10]
push eax
mov ecx, numlocal
imul ecx, ecx, CharWidth
add ecx, 2
add ecx, decimal BoxLeft
add ecx, AddForFace
push decimal BoxUp
push ecx
push 48F91C
call renderGraphics
add esp, 14

;Clear text bmp
push 3
push 0
push 498290
call 40CA80
add esp, 0C

;Write text to bmp
xor eax, eax
mov counter, eax
jmp :WriteTextLoop
:WriteTextTop
inc counter
:WriteTextLoop
mov eax, counter
cmp eax, numchar
jge :WriteTextOut
mov ecx, strlocal
add ecx, eax
data 0F B6 11		;movzx edx, byte [ecx]
mov charbuf, edx
push 3
push FEFFFF
lea eax, charbuf
push eax
push 0
mov ecx, counter
imul ecx, ecx, charwidth
push ecx
call 40CEB0
add esp, 14
jmp :WriteTextTop
:WriteTextOut

;Draw to screen
push 3
push 498290
push decimal TextUp
mov eax, decimal textleft
add eax, addforface
push eax
push 48f91C
call rendergraphics
add esp, 14

leave
retn

